﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    public class FuelCar : Car, IFuelBased
    {
        private const float k_MaximumFuelCapacity = 55.0f;
        private const FuelEngine.eFuelType k_FuelType = FuelEngine.eFuelType.Octan98;
        private FuelEngine m_FuelEngine;

        public FuelCar()   
        {
            m_FuelEngine = new FuelEngine(k_FuelType, 0.0f, k_MaximumFuelCapacity);
        }

        public override void ParseFields(Dictionary<string, string> i_Form)
        {
            base.ParseFields(i_Form);
            float percentage = (float.Parse(RemainingEnergyPercentage) / 100) * FuelPowerSource.MaximumFuelLevel;
            RemainingEnergyPercentage = percentage.ToString();
        }

        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.ToString());
            stringBuilder.Append(m_FuelEngine.ToString());

            return stringBuilder.ToString();
        }

        public FuelEngine FuelPowerSource
        {
            get { return m_FuelEngine; }
        }

        public void Refuel(float i_LitresToAdd, FuelEngine.eFuelType i_FuelType, ref Vehicle io_Vehicle)
        {
            m_FuelEngine.Refuel(i_LitresToAdd, i_FuelType, ref io_Vehicle);
        }
    }
}
